<template>
  <div id="app">
    <el-container style="border: 1px solid #eee">
      <el-aside
        width="300px"
        style="height:calc(100vh - 5px);background-color: rgb(238, 241, 246);overflow-y:auto"
      >
        <el-menu :default-active="index">
          <el-menu-item index="/index" @click="menuclick('/index')">介绍</el-menu-item>
          <el-menu-item index="/container" @click="menuclick('/container')">容器</el-menu-item>
          <el-menu-item index="/loading" @click="menuclick('/loading')">加载中</el-menu-item>
          <el-menu-item index="/borderBox" @click="menuclick('/borderBox')">边框</el-menu-item>
          <el-menu-item index="/decoration" @click="menuclick('/decoration')">装饰物</el-menu-item>
          <el-submenu index="4">
            <template slot="title">
              <span>图表</span>
            </template>
            <el-menu-item index="/charts/basic" @click="menuclick('/charts/basic')">基础配置说明</el-menu-item>
            <el-menu-item index="/charts/line" @click="menuclick('/charts/line')">折线图</el-menu-item>
            <el-menu-item index="/charts/histogram" @click="menuclick('/charts/histogram')">柱状图</el-menu-item>
            <el-menu-item index="/charts/bar" @click="menuclick('/charts/bar')">条形图</el-menu-item>
            <el-menu-item index="/charts/pie" @click="menuclick('/charts/pie')">饼图</el-menu-item>
            <el-menu-item index="/charts/ring" @click="menuclick('/charts/ring')">环图</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <el-container
        style="height:calc(100vh - 5px);background-color: rgb(238, 241, 246);overflow-y:none"
      >
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  methods: {
    menuclick(url) {
      this.$router.push(url);
    }
  },
  computed: {
    index() {
      let url = window.location.href;
      if (url.indexOf("#") < 0 || url.split(/#/)[1] == "") return "";
      return url.split(/#/)[1];
    }
  }
};
</script>

<style >
body {
  margin: 0;
  padding: 0;
}
#app {
  height: 100vh;
}

.el-aside {
  color: #333;
}
.el-main {
  display: flex;
  justify-content: center;
  align-content: center;
  flex-wrap: wrap;
  text-align: center;
}
</style>
